<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="md5/md5.js"></script>
	<style type="text/css">
	</style>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#submit").click(function(){
				var form = document.getElementById("feedForm");
				//alert(form.type.value+"?"+form.userIds.value+"?"+form.ownerId.value+
				//		"?"+form.userNames.value);
				//var param = '{"type":"'+form.type.value+'","userIds":"'+
	           //    form.userIds.value+'","ownerId":"'+form.ownerId.value+
	           //    '","title":"'+form.title.value+'","content":"'+form.content.value+'"}';
	           //    alert(param);
	           var param = '{"type":"'+form.type.value+'","userIds":"'+
			               form.userIds.value+'","ownerId":"'+form.ownerId.value+
			               '","title":"'+
			               form.title.value+'","content":"'+
			               form.content.value+'"}';
		/*jQuery.ajax({
			url:"/api/feed/send_message",
			type:"POST",
			contentType:"application/json",
			dataType:"json",
			//data:jQuery("#feedForm").serializeArray(),
			data:param,
			success:function(r){
				alertify.success(r.message);
			},
			error:function(e){
			   alert("发送失败，请联系管理员");
			 }
		});*/
				$.ajax({
					url:"/api/feed/send_message",
					//url:"http://10.10.62.117:8080/login?api_login=true",
					//url:"http://127.0.0.1:8088/cas/api/account/checklogin",
					type:"POST",
					contentType:"application/json",
					dataType:"json",
					data:param,
					success:function(r){
						//console.log(r);
						alert(r.message);
						//alert(r.data.SESSION_TOKEN);
					}
				});
			});
			$("#readsubmit").click(function(){
				var form = document.getElementById("feedReadForm");
				$.ajax({
					url:"/api/feed/read",
					//url:"http://10.10.62.117:8080/login?api_login=true",
					//url:"http://127.0.0.1:8088/cas/api/account/checklogin",
					type:"POST",
					data:$("#feedReadForm").serialize(),
					success:function(r){
						//console.log(r);
						alert(r.message);
						//alert(r.data.SESSION_TOKEN);
					}
				});
			});
			$("#deletesubmit").click(function(){
				var form = document.getElementById("feedDeleteForm");
				$.ajax({
					url:"/api/feed/delete",
					//url:"http://10.10.62.117:8080/login?api_login=true",
					//url:"http://127.0.0.1:8088/cas/api/account/checklogin",
					type:"POST",
					data:$("#feedDeleteForm").serialize(),
					success:function(r){
						//console.log(r);
						alert(r.message);
						//alert(r.data.SESSION_TOKEN);
					}
				});
			});
			$("#querysubmit").click(function(){
				var form = document.getElementById("queryForm");
				$.ajax({
					url:"/api/feed/get_list",
					//url:"http://10.10.62.117:8080/login?api_login=true",
					//url:"http://127.0.0.1:8088/cas/api/account/checklogin",
					type:"GET",
					data:$("#queryForm").serialize(),
					datatype:"text",
					success:function(r){
						//console.log(r);
						//alert(r.data.SESSION_TOKEN);
						$("#resultTextarea").html( JSON.stringify(r));
					}
				});
			});
		});
		function doAjax(method,url,parm){
			$.ajax({
				url:url,
				type:method,
				data:parm,
				success:function(r){
					console.log(r);
					$("#resultTextarea").val(JSON.stringify(r));
				},
				error:function(XMLHttpRequest, textStatus, errorThrown){
					console.log(XMLHttpRequest.responseText);
					$("#resultTextarea").val(XMLHttpRequest.responseText);
				}
			});
		}
		function doJsonAjax(method,url,parm){
			$.ajax({
				url:url,
				type:method,
				contentType:"application/json",
				data:JSON.stringify(parm),
				success:function(r){
					console.log(r);
					$("#resultTextarea").val(JSON.stringify(r));
				},
				error:function(XMLHttpRequest, textStatus, errorThrown){
					console.log(XMLHttpRequest.responseText);
					$("#resultTextarea").val(XMLHttpRequest.responseText);
				}
			});
		}
	</script>
</head>
<style type="text/css">
.table{
	border-collapse:collapse;
	width:700px;
}
.table td,.table th{
	border:1px solid #ccc;
}
</style>
<body>
<fieldset>
   <legend>app发送消息</legend>
   <form id="feedForm" method="post">
		消息APPID:<input type="text" name="ownerId" value=""></input>
		消息主题：<input type="text" name="title" value="title"></input>
		消息概要：<input type="text" name="content" value="content"></input>
		消息类型：<input type="text" name="type" value="app"></input>
		UserIds：<input type="text" name="userIds" value="app"></input>
		<input id="submit" type="button" value="发送"></input>
	</form>
</fieldset>
<fieldset>
   <legend>已读消息</legend>
   <form id="feedReadForm" method="post">
		消息APPID:<input type="text" name="ownerId" value=""></input>
			UserId：<input type="text" name="userId" value="app"></input>
		<input id="readsubmit" type="button" value="已读"></input>
	</form>
</fieldset>	
<fieldset>
   <legend>删除消息</legend>
   <form id="feedDeleteForm" method="post">
		消息APPID:<input type="text" name="ownerId" value=""></input>
		<input id="deletesubmit" type="button" value="删除"></input>
	</form>
</fieldset>	
<fieldset>
   <legend>查询消息</legend>
   <form id="queryForm" method="get">
		UserId:<input type="text" name="userId" value=""></input>
   <input id="querysubmit" type="button" value="查询"></input>
   </form>
<p id="resultTextarea"></p>
</fieldset>
</body>
</html>
